
<div class="layui-body-header">
	<a href="#/layui/meetList" class="layui-btn layui-btn-xs layui-btn-primary" style="margin: -0px 0 0 0;border: none;background-color: rgba(0,0,0,0);">
															  <i class="layui-icon">&#xe65c;</i>
															</a>
	考勤列表
</div>

<div class="layui-card-body">
	<div class="layui-fluid">
		<div class="layui-card">
          <div class="layui-card-header">
            <!-- <span>所有会员列表</span> -->
            <!--<button type="button" class="layui-btn layui-btn-sm layui-btn-primary changeInte">
              <i class="layui-icon">&#xe673;</i>
              <span>变更等级积分</span>
            </button>-->
            <button type="button" class="layui-btn layui-btn-sm layui-btn-primary check">
              <i class="layui-icon">&#xe63c;</i>
              <span>签到</span>
            </button>
            <!--<button type="button" class="layui-btn layui-btn-sm layui-btn-danger batchDel">
              <i class="layui-icon">&#xe640;</i>
              <span>批量删除</span>
            </button>-->
            <!--<a href="#/member/all/edit" class="layui-btn layui-btn-sm layui-btn-primary">
              <i class="layui-icon">&#xe62f;</i>
              <span>导出到Excel</span>
            </a>-->
            <a href="javascript:;" class="layui-btn layui-btn-sm layui-btn-primary" id="search_hash">
              <i class="layui-icon">&#xe615;</i>
            </a>
          </div>
          <div class="layui-card-body">
            <table id="memberListTable" lay-filter="test"></table>
            <script type="text/html" id="barDemo_hash">
            	<!--<a class="layui-btn layui-btn-xs layui-btn-primary" lay-event="changeScore">变更等级积分</a>-->
              <!--<a class="layui-btn layui-btn-xs" lay-event="detail">编辑</a>-->	
              <!-- <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a> -->
              <!--<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>-->
            </script>
          </div>
        </div>
      </div>
    </div>
      
      

<script type="text/html" id="search_tpl_hash">
  <form class="layui-form" action="">
    <!--<div class="layui-form-item">
      <label class="layui-form-label">会员ID</label>
      <div class="layui-input-block">
        <input type="text" name="memId" placeholder="" autocomplete="off" class="layui-input">
      </div>
    </div>-->
    <div class="layui-form-item">
      <label class="layui-form-label">会员姓名</label>
      <div class="layui-input-block">
        <input type="text" name="memName" id="memName"  placeholder="" autocomplete="off" class="layui-input">
      </div>
    </div>
    <!--<div class="layui-form-item">
      <label class="layui-form-label">联系电话</label>
      <div class="layui-input-block">
        <input type="text" name="tel" placeholder="" autocomplete="off" class="layui-input">
      </div>
    </div>-->
    <!--<div class="layui-form-item">
      <label class="layui-form-label">会员等级</label>
      <div class="layui-input-block">
        <select name="memLev" class="memLev">
          <option value="">全部</option>
        </select>
      </div>
    </div>-->
    <div class="layui-form-item">
      <div class="layui-input-block">
        <button class="layui-btn" lay-submit lay-filter="formDemo_hash"><i class="layui-icon">&#xe615;</i> 搜索</button>
        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
      </div>
    </div>
  </form>
</script>

<script type="text/javascript" src="../../api/DBHelper.js"></script>
<script>
	let delAll = document.querySelector(".delAll");
	let changeInte = document.querySelector(".changeInte");
	let checked = '';
	let thisObj='';
	let editMem = document.querySelector(".editMem");
	let batchDel = document.querySelector(".batchDel");
	let check = document.querySelector(".check");
	let checkedArr = [];
	let objArr = [];	
	let _obj = {
		  "Guid": "00000000-0000-0000-0000-000000000000",
		  "MeetingGuid": "",
		  "MemberGuid": "",
		  "CreateUser": localStorage.getItem("user"),
		  "CreateTime": ""
	};
	
	
  layui.use(['jquery', 'mockjs', 'table', 'sidebar', 'form' , 'route'], function () {
    var $ = layui.jquery,
      layer = layui.layer,
      table = layui.table,
      sidebar = layui.sidebar,
      route = layui.route,
      params = route.params(),
      form = layui.form;
    // 注入mock
    layui.mockjs.inject({
      'POST /demo/table/user': {
        code: 0,
        msg: "xxx",
        count: 1000,
        'data|20': [{
          'id|+1': 1,
          username: '@name',
          sex: '@boolean',
          city: '@city',
          sign: '@csentence',
          experience: '@integer',
          score: '@integer',
          classify: '@word',
          wealth: '@integer',
          auth: '@boolean'
        }]
      }
    });
    //第一个实例
    table.render({
      method: 'post',
      // size: 'sm',
      limit: 10,
      limits: [10,20,30],
      elem: '#memberListTable',
      id:'test',
      height: 'full-235',
      url: 'https://xnsmb.xnsoft.net.cn/api/Filtrate_Xn_Member', //数据接口
      page: true, //开启分页
      contentType: 'application/json',
      where: {
      	"MemLoginId": "",
			  "RealName": "",
			  "Mobile": "",
			  "RankGuid": ""
      },
      parseData: function(res){
      	return {
      		'code':0,
      		'count':res.TotalCount,
      		"data":res._Data
      	};
      },
      request: {
		    pageName: 'CurrentPage' //页码的参数名称，默认：page
		    ,limitName: 'PageSize' //每页数据量的参数名，默认：limit
		  },
      cols: [
        [ //表头
          {
//          width: 150,
            fixed: 'left',
            type: 'checkbox'
          },{
            field: 'MemLoginId',
            title: '会员ID',
//          width: 150
          }, {
            field: 'RealName',
            title: '会员姓名',
//          width: 150
          }, {
            field: 'Mobile',
            title: '手机号',
//          width: 150
          }, {
            field: 'RankName',
            title: '会员等级',
//          width: 150
          }, {
            field: '',
            title: '职位',
//          width: 150
          },{
            field: '',
            title: '行业',
//          width: 150
          },{
            field: 'LikeCount',
            title: '关注人数',
//          width: 150
          },{
            field: 'CollectCount',
            title: '收藏人数',
//          width: 150
          },{
            field: 'TransmitCount',
            title: '好友人数',
//          width: 150
          },{
            fixed: 'right',
//          width: 230,
            align: 'center',
            toolbar: '#barDemo_hash'
          }
        ]
      ]
    });

    $('#search_hash').on('click', function () {
      var that = this;
      // console.log($('#search_tpl_hash').html());
      sidebar.render({
        elem: that,
        content: $('#search_tpl_hash').html(),
        title: '搜索',
        shade: true,
        // shadeClose:false,
        // direction: 'left'
        // dynamicRender: false,
        // url: 'views/member/all/search.html',
        width: '500px', //可以设置百分比和px
        done: function () {
        	let memLev = document.querySelector(".memLev");
          console.log('ccc',memLev);
          form.render();
          
          

          //监听提交
          form.on('submit(formDemo_hash)', function (data) {
            // layer.msg(JSON.stringify(data.field));
            table.reload('test', {
             where: {
                		"MemLoginId": "",
						"RealName": $("#memName").val(),
						"Mobile": "",
						"RankGuid": ""
              }
            });
            return false;
          });
          
        }
      });
    });
    
			table.on('checkbox(test)', function(obj){
//		  console.log("obj.checked",obj.checked); //当前是否选中状态
//		  console.log("obj.data",obj.data); //选中行的相关数据
//		  console.log("obj.type",obj.type); //如果触发的是全选，则为：all，如果触发的是单选，则为：one
			console.log(obj.data)
			if(obj.type=="one"){
				if(obj.checked){
					objArr.push(obj)
					checkedArr.push(obj.data.Guid)
					console.log(objArr)
				}else if(!obj.checked){
					objArr.splice(objArr.indexOf(obj.data),1)
					checkedArr.splice(checkedArr.indexOf(obj.data.Guid),1)
					console.log(objArr)
				}
			}
		
		});
    
//  "#/layui/addFenhui?id="
    table.on('tool(test)',function(obj){
    	toolHandel("#/layui/ediMember?id=","Admin_Xn_Member/",obj,"","","#/layui/changeLev?id=");
    })
    
    
    
//  批量删除
//  batchDel.addEventListener("click",function(){
//  	batDel("Admin_Xn_Member/",checkedArr,objArr)
//  	
//  })
    
//  batchDel.addEventListener("click",function(){
//			layer.confirm('确认删除？', function(index){
//					layer.close(index);	
//					console.log("checkedArr",checkedArr)
//					DBHelper.Delete("Admin_Xn_Member",checkedArr,function(data){
//				      	console.log(data)
//				      },function(data){
//				      	table.reload('test', {
//								});
//				      	console.log(data)
//				      })
//					
//		    });
//			
//  })
    
	//  变更等级积分
//	changeInte.addEventListener("click",function(data){
////		console.log("HI")
//		if(checkedArr.length>1){
//			layer.alert("请不要选择超过两个选项")
//		}else if(checkedArr.length==1){
//			window.location.href="#/layui/changeLev?id="+checkedArr[0];
//		}
//	})
	
	check.addEventListener("click",function(){
		
		if(checkedArr.length>1){
			layer.alert("请不要选择超过两个选项")
		}else if(checkedArr.length==1){
			_obj.MeetingGuid = params.id;
			_obj.MemberGuid = checkedArr[0];
			_obj.CreateTime = getNowFormatDate();
			console.log("_obj",_obj);
			DBHelper.Post("Admin_Xn_MeetingMember",_obj,function(data){
				console.log(data,"成功添加");
				let index = layer.confirm('考勤成功',function(){
					location.href = window.location.href
					layer.close(index)
				})
//				layer.msg('考勤成功',function(){
//					window.location.reload()
//				})
			},function(data){
				console.log(data)
				let index = layer.confirm('该会员已签到',function(){
					location.href = window.location.href
					layer.close(index)
				})
			})
		}
	})
		
  });
  
  

</script>
<script type="text/javascript">
	let mlTable = document.querySelector("#memberListTable");
	console.log(mlTable);
	
</script>



<style scoped>
	.qxMaBtn{
		margin-bottom: 20px;
	}
		.qxMaInfo-table{
			font-size: 12px;
		}
		.qxMaInfo-table tr>th{
			text-align: center;
			font-size: 12px;
		}
		.qxMaInfo-table tr>td{
			text-align: center;
			font-size: 12px;
		}
      	.block{
      		display: block;
      	}
      	.qxMaTop-btn{
      		width: 100%;
      		text-align: center;
      	}
      	.qxMaInfo{
      		margin-top: 20px;
      		margin-bottom: 30px;
      	}
      	.qxMaTop-btn button{
      		display: inline-block;
      		width: 200px;
      		border-radius: 5px;
      	}
      	.title{
      		margin-left: 30px;
      		margin-top: 30px;
      	}
      	.save-warp{
      		width: 100%;
      		text-align: center;
      		margin-top: 20px;
      	}
      	.save-warp button{
      		display: inline-block;
      		width: 160px;
      	}
      	.qxMa-top{
      		display: flex;
      		justify-content: space-between;
      	}
      	.qxMa-table{
      		background-color: rgba(0,0,0,0);
      	}
      	
      	
      </style>

<script type="text/javascript">
//      1.创建对象
        var xhr = new XMLHttpRequest();
//      2.发送请求 open方法
        xhr.open("GET","https://xnsmb.xnsoft.net.cn/api/Admin_Xn_Member");//注册用什么方式，去哪里请求
//      3.将请求发送出去 send方法
        xhr.send();
//      4.处理数据
        xhr.addEventListener("readystatechange",function(e){
                if(e.target.readyState==4 && e.target.status==200 ){
                    console.log(e.target.response);
                    renderData(e.target.response);
                    console.log(JSON.parse(e.target.response));
                    
                }
            })
</script>



